var LRUCache = function(capacity) {
    this.max = capacity;
    this.map = new Map();

    
};


LRUCache.prototype.get = function(key) {
    const value = this.map.get(key) ;
    if(value === undefined){
        return -1;
    }
    if(value !== -1){
        //调整位置
        this.map.delete(key);
        this.map.set(key,value);
    }
    return value;

};

LRUCache.prototype.put = function(key, value) {
    if (this.map.has(key)) {
        this.map.delete(key);
    }

    this.map.set(key, value);
    if (this.map.size > this.max) {  
        const keys = this.map.keys();//返回一个迭代器
        const oldestKey = keys.next().value;
        this.map.delete(oldestKey);
    }
};



let head ={
    val:0,
    next:{
        val:1,
        next:{
            val:2,
            next:null
        }
    }
}

let map = {
    a:1,
    b:2,
    c:3
}

delete map[1]
